
export function dateFormat(dt) {
  if (dt == null) {
    dt = new Date()
  } else if (!(dt instanceof Date) && !isNaN(dt) ) {
    dt = new Date(dt)
  }

  let year = dt.getFullYear()
  let month = dt.getMonth() + 1
  let date = dt.getDate()
  let minutes = dt.getMinutes()
  let seconds = dt.getSeconds()

  if (month < 10) month = '0' + month
  if (minutes < 10) minutes = '0' + minutes
  if (seconds < 10) seconds = '0' + seconds
  
  return `${year}-${month}-${date} ${minutes}:${seconds}`
}

export function getQuery() {
  let query = {}
  let queryStr = location.href.split('?')[1]
  let queryArr = queryStr.split(';')
  queryArr.forEach(item => {
    const key = item.split('=')[0]
    const val = item.split('=')[1]
    query[key] = val
  })
  return query
}